const mongoose = require("mongoose")
const { Schema, model } = mongoose

const StoresSchema = new Schema({
    id_store: {
        type: Number,
        unique: true,
        required: [true, "需要ID"],
    },
    name: {
        type: String,
        unique: true,
        minlength: 0,
        maxlength: 15,
        required: [true, "请输入店铺名"],
        trim: true,
    },
    owner: {
        type: Schema.Types.ObjectId,
        default: "62ceb326196299b14c392dad",
        ref: "Users",
        required: true
    },
    staff: {
        type: [Schema.Types.ObjectId],
        default: "62ceb326196299b14c392dad",
        ref: "Users",
    },
    cover: {
        type: String,
        default: "无",
        trim: true,
    },
    drama: {
        type: [Schema.Types.ObjectId],
        default: ["62c133a5c8a094e98dfbca5c", "62c14b024cfa7b77a69ed9cd"],
        ref: "Dramas",
    },
    score: {
        type: Number,
        default: 0.1,
    },
    auth: {
        type: String,
        default: "false",
        enum: ["false", "true"]
    },
    active: {
        type: String,
        default: "false",
        enum: ["false", "true"]
    },
    address: {
        province: {
            type: String,
            default: "江苏省",
        },
        prefecture_city: {
            type: String,
            default: "苏州市",
        },
        county_city: {
            type: String,
            default: "昆山市",
        },
        location: {
            type: String,
            default: "苏州大学应用技术学院",
        },
        longitude: {
            type: Number,
            default: "120.8424",
        },
        latitude: {
            type: Number,
            default: "31.14922",
        }
    },
    worktime: {
        startday: {
            type: String,
            default: "周一",
            enum: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
        },
        endday: {
            type: String,
            default: "周日",
            enum: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
        },
        starthour: {
            type: String,
            default: "9",
            enum: ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24"]
        },
        endhour:{
            type: String,
            default: "21",
            enum: ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24"]
        },
    }

}, { timestamps: true, versionKey: false })

module.exports = model("Stores", StoresSchema, "Stores")